package com.item.service.impl;

import com.github.pagehelper.PageHelper;
import com.item.domain.UserRole;
import com.item.mapper.UserRoleMapper;
import com.item.service.UserRoleService;
import com.item.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRoleServiceImpl implements UserRoleService {

    @Autowired
    UserRoleMapper userRoleMapper;


    public List<UserRole> findAll(int limit, int page, UserRole userRole) {
        if (limit > 0 && page > 0) {
            PageHelper.startPage(limit, page);
        }
        return userRoleMapper.findAll(userRole);
    }


    public int add(UserRole userRole) {
        return userRoleMapper.insertSelective(userRole);
    }


    public int update(UserRole userRole) {
        return userRoleMapper.updateByPrimaryKey(userRole);
    }

    @Override
    public int delete(int id) {
        return userRoleMapper.deleteByPrimaryKey(id);
    }
}
